In [ ]:

  • Linear transformations
    • Fundamental spaces
      • Vector spaces
    • Matrix representations
    • Eigenvectors and eigenvalues
    • Invertible matrix theorem
  • Further topics
    • Analytical geometry
      • Points, lines, and planes
      • Projections
      • Distances
    • Abstract vector spaces
      • Vector space of polynomials, e.g. $p(x)=a_0 + a_1x + a_2x^2$
    • Special types of matrices
    • Matrix decompositions
    • Linear algebra over other fields

In [ ]:

Fundamental spaces


In [49]:
# Recall the linear transformation P we constructed above
M_P = Matrix([[1,1],
              [1,1]])/2

def P(vec):
    """Compute the projection of vector `vec` onto line y=x."""
    return M_P*vec

In [50]:
# null space of M_P == kernel of P
M_P.nullspace()


Out[50]:
$$\left [ \left[\begin{matrix}-1\\1\end{matrix}\right]\right ]$$

In [51]:
# any vector from the null space gets mapped to the zero vector
n = M_P.nullspace()[0]
P(n)


Out[51]:
$$\left[\begin{matrix}0\\0\end{matrix}\right]$$

In [52]:
# column space of M_P == image of P
M_P.columnspace()


Out[52]:
$$\left [ \left[\begin{matrix}\frac{1}{2}\\\frac{1}{2}\end{matrix}\right]\right ]$$

In [53]:
# all outputs of P lie on the line y=x so are multiples of [1,1]
v = Vector([4,5])
P(v)


Out[53]:
$$\left[\begin{matrix}\frac{9}{2}\\\frac{9}{2}\end{matrix}\right]$$

Vector spaces

The above examples consist of a single vector, but in general a vector space can consist of linear combination of multiple vectors:

$$ V = \textrm{span}(\vec{v}_1, \vec{v}_2 ) = \{ \alpha\vec{v}_1 + \beta\vec{v}_2, \forall \alpha, \beta \in \mathbb{R} \}. $$

Eigenvectors and eigenvalues

When a matrix is multiplied by one of its eigenvectors the output is the same eigenvector multiplied by a constant

$$ A\vec{e}_\lambda =\lambda\vec{e}_\lambda. $$

The constant $\lambda$ is called an eigenvalue of $A$.


In [ ]:
# Recall the P, the projection onto the y=x plane and its matrix M_P
M_P

In [ ]:
M_P.eigenvals()

In [ ]:
M_P.eigenvects()

In [ ]:
evec0 = M_P.eigenvects()[0][2][0]
evec1 = M_P.eigenvects()[1][2][0]

plot_line([1,1],[0,0])
plot_vecs(evec0, evec1)

In [ ]:
M_P*evec0  # == 0*evec0

In [ ]:
M_P*evec1  # == 1*evec1

Many other topics...

Analytical geometry

Points, lines, planes, and distances

Useful geomtetric calculations and intuition.

Projections

Projections onto lines (as above), planes, hyperplanes, coordinate projections, etc.

Invertible matrix theorem

Summarizes and connects computational, geometric, and theoretical aspects of linear algebra.

Abstract vector spaces

Vector space of matrices e.g. $A = \begin{bmatrix}a_1 & a_2 \\ a_3 & a_4 \end{bmatrix}$

Vector space of polynomials, e.g. $p(x)=a_0 + a_1x + a_2x^2$


In [ ]:

Special types of matrices


In [ ]:
# diagonal
D = Matrix([[1,0],
            [0,4]])
D

In [ ]:
# upper triangular
U = Matrix([[1,2],
            [0,3]])
U

In [ ]:
# symmetric
S = Matrix([[1,2],
            [2,3]])
S == S.T

Matrix decompositions


In [ ]:
A = Matrix([ [4,2],
             [1,3] ]) 
A

In [ ]:
# decompose matrix into eigenvectors and eigenvalues
Q, Lambda = A.diagonalize()
Q, Lambda, simplify( Q*Lambda*Q.inv() )

In [ ]:
# decompoe matrix A into a lower-triangular and upper triangular 
L, U, _ = A.LUdecomposition()
L, U, L*U

In [ ]:
Q, R = A.QRdecomposition()
Q, R, Q*R

In [ ]:
Q*Q.T

Linear algebra over other fields


In [ ]:
# Finite field of two elements F_2 = {0,1}  (Binary numbers)
(1+6) % 2
# applications to cryptography, error correcting codes, etc.

In [ ]:
# Complex field  z = a+bi, where i = sqrt(-1)
v = Vector([1, I])
v

In [ ]:
v.H

In [ ]:
# used in communication theory and quantum mechanics